<template>
  <border-box title="选题外链">
    <span slot="titleRight" @click="lookLink">查看外链</span>
    <div>
      <a-tag v-for="(item,index) in linkList" :key="index">
        <a :href="item.url" target="_blank">{{item.name}}</a>
      </a-tag>
    </div>
    <topic-link-model ref="linkModal" :link-list="linkList" :task-no="params.taskNo"
                      @updateLink="updateLink"></topic-link-model>
  </border-box>
</template>

<script>
  //选题外链
  import BorderBox from "../BorderBox";
  import TopicLinkModel from "./TopicLinkModel";
  import {getAction} from "@/api/manage";

  export default {
    name: "TopicLink",
    components: {TopicLinkModel, BorderBox},
    props: ['params'],
    data() {
      return {
        linkList: []
      }
    },
    created() {
      this.queryLinkList()
    },
    methods: {
      lookLink() {
        this.$refs.linkModal.show(this.linkList);
      },
      queryLinkList() {
        getAction('task/taskInfo/queryTaskAttachOutLink', this.params).then(res => {
          if (res.success) {
            this.linkList = res.result;
          }
        })
      },
      updateLink(links) {
        this.linkList = links;
      }
    }
  }
</script>

<style scoped>

</style>